﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MarvellousWorks.PracticalPattern.Concept.Delegating
{
    public class AsyncInvoker
    {
        // 记录异步执行的结果
        private IList<string> output = new List<string>();

        public AsyncInvoker()
        {
            Timer slower = new Timer(new TimerCallback(OnTimeInterval),"slower",2500,2500);
            Timer faster = new Timer(new TimerCallback(OnTimeInterval), "faster", 1000, 1000);
            output.Add("AsyncInvoker created");
        }

        private void OnTimeInterval(object state)
        {
            output.Add($"{state}");
        }

        public IList<string> GetOutput()
        {
            return output;
        }
    }
}
